Guided Practice 1.2
Here is an example based on Exercise 94 from HtDP/2e:
Design a data representation for the following four kinds of zoo
animals:
- spiders, whose relevant attributes are the number of
remaining legs (we assume that spiders can lose legs in accidents)
and the space they need in case of transport;
- elephants, whose only attributes are the space they need in case
of transport;
- boa constrictor, whose attributes include length and girth; and
- armadillo, for whom you must determine appropriate attributes;
they need to include attributes that determine space needed for
transportation.
Write a data definition for ZooAnimal. Be sure to include:
- Structure Definitions
- Constructor Template
- Interpretation
- Observer Template
- Examples
Here is a solution. But
remember, no peeking! You won't get anything out of this exercise if
you don't write down your solution first.
Last modified: Mon Jul 25 23:32:37 Eastern Daylight Time 2016